package mips.instructions;

import mips.structure.MipsInstr;
import mips.value.MipsValue;
import mips.value.Register;

public class Loading extends MipsInstr {
    private MipsValue src;
    private MipsValue dst;
    private String type;

    public Loading(MipsValue dst, MipsValue src) {
        this.src = src;
        this.dst = dst;
        type = "lw";
    }

    public Loading(MipsValue dst, MipsValue src, String type) {
        this.src = src;
        this.dst = dst;
        this.type = type;
    }

    @Override
    public String toString() {
        if (type.equals("lw")) {
            if (src instanceof Register)
                return "lw " + dst + ", 0(" + src + ")";
            else
                return "lw " + dst + ", " + src;
        } else if (type.equals("li")) {
            return "li " + dst + ", " + src;
        } else {
            if (src instanceof Register)
                return "la " + dst + ", 0(" + src + ")";
            else
                return "la " + dst + ", " + src;
        }
    }

}
